package com.rerun.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.rerun.entity.EduBackground;
import com.rerun.mapper.EduBackgroundMapper;
import com.rerun.service.IEduBackgroundService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * The type Edu background service.
 *
 * @author dax.
 * @version v1.0
 * @since 2017 /9/29 9:12
 */
@Service
public class EduBackgroundServiceImpl extends ServiceImpl<EduBackgroundMapper,EduBackground> implements IEduBackgroundService {
    @Resource
    private EduBackgroundMapper eduBackgroundMapper;
    @Override
    public EduBackground selectByPhoneNumber(String phoneNumber) {
        return eduBackgroundMapper.selectByPhoneNumber(phoneNumber);
    }

    @Override
    public List<EduBackground > selectByMemberId(String memberId) {
        return eduBackgroundMapper.selectByMemberId(memberId);
    }

    @Override
    public void updateMemberIdTask() {
        List<String> phoneNumbers = selectPhoneNumberNoMemberId();
        if (CollectionUtils.isNotEmpty(phoneNumbers)) {
            for (String phoneNumber:phoneNumbers){
                eduBackgroundMapper.updateMemberIdTask(phoneNumber);
            }
        }
    }

    @Override
    public List<String> selectPhoneNumberNoMemberId() {
        return eduBackgroundMapper.selectPhoneNumberNoMemberId();
    }
}
